home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************************
- *
- * @@@BUILDINFO@@@ 05menus.jsx 1.0.0.48 07-Feb-2005
- * Copyright 2005 Adobe Systems Incorporated
- * All Rights Reserved.
- *
- * NOTICE: All information contained herein is, and remains the property of
- * Adobe Systems Incorporated and its suppliers, if any. The intellectual
- * and technical concepts contained herein are proprietary to Adobe Systems
- * Incorporated and its suppliers and may be covered by U.S. and Foreign
- * Patents,patents in process,and are protected by trade secret or copyright
- * law. Dissemination of this information or reproduction of this material
- * is strictly forbidden unless prior written permission is obtained from
- * Adobe Systems Incorporated.
- **************************************************************************/
-
- /////////////////////////////////////////////////////////
-
- // The Recent Files menu
- // This menu holds as many as 9 entries. The entries are part of the pref object's
- // recentFiles array. The menu needs to be set up as the number of entries grow.
-
- fileMenu = MenuElement.find ("file");
- fileMenu.recentFiles = new MenuElement ("menu", "$$$/ESToolkit/Menu/File/Recent=Recent &Files",
- "after file/open", "file/recent");
-
- fileMenu.recentFiles.onDisplay = function()
- {
- var index = 1;
- for (var i = 0; i < prefs.recentFiles.length; i++)
- {
- var f = new File (prefs.recentFiles [i]);
- if (f.exists)
- {
- var cmdID = "menu/file/recent" + index;
- var text = "";
- if ($.os.indexOf ("Win" >= 0))
- // Windows: start with an index
- text = "&" + index + " ";
- text += decodeURIComponent (f.name);
- var element = MenuElement.find (cmdID);
- if (!element)
- element = new MenuElement ("command", text, "at the end of file/recent", cmdID);
- else
- element.text = text;
- element.file = f;
- element.index = i;
- element.enabled = true;
- element.onSelect = function()
- {
- // Move the entry to the top
- text = prefs.recentFiles [this.index];
- prefs.recentFiles.splice (this.index, 1);
- prefs.recentFiles.splice (0, 0, text);
- Document.create (this.file);
- }
- index++;
- }
- }
- this.enabled = (prefs.recentFiles.length > 0);
- }
-
- /////////////////////////////////////////////////////////////////////////
- // Set up the Edit menu. The Preferences item is on the App menu on the Mac.
-
- var editMenu = MenuElement.find ("edit");
- editMenu.lines = MenuElement.find ("edit/lines");
- editMenu.hilite = MenuElement.find ("edit/hilite");
- editMenu.check = MenuElement.find ("edit/check");
- editMenu.findReplace = MenuElement.find ("edit/findReplace");
- editMenu.findNext = MenuElement.find ("edit/findNext");
- editMenu.preferences = MenuElement.find ("tools/preferences");
-
- editMenu.lines.enabled =
- editMenu.hilite.enabled =
- editMenu.check.enabled = true;
- if (editMenu.preferences) editMenu.preferences.enabled = true;
-
- editMenu.findReplace.onDisplay = function()
- {
- this.enabled = (document != null);
- }
-
- editMenu.lines.onSelect = function()
- {
- this.checked = !this.checked;
- prefs.lineNumbers = this.checked;
- return true;
- }
-
- editMenu.hilite.onSelect = function()
- {
- this.checked = !this.checked;
- prefs.hilite = this.checked;
- return true;
- }
-
- editMenu.check.onSelect = function()
- {
- if (document != null)
- {
- // check the syntax and display the result in the status line
- var result = document.checkSyntax (app.includePath);
- if (result != true)
- {
- window.statusLine = result;
- app.beep();
- }
- else
- window.statusLine = localize ("$$$/ESToolkit/Alerts/SyntaxOK=No syntax errors");
- }
- return true;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // The Debug menu.
-
- var debugMenu = MenuElement.find ("debug");
- debugMenu.run = MenuElement.find ("debug/run");
- debugMenu.stop = MenuElement.find ("debug/stop");
- debugMenu.pause = MenuElement.find ("debug/break");
- debugMenu.into = MenuElement.find ("debug/into");
- debugMenu.over = MenuElement.find ("debug/over");
- debugMenu.out = MenuElement.find ("debug/out");
- debugMenu.bptoggle = MenuElement.find ("debug/bptoggle");
- debugMenu.bpclearall = MenuElement.find ("debug/bpclearall");
- debugMenu.noErrors = new MenuElement ("command", "$$$/ESToolkit/Menu/Debug/DontBreakOnErrors=Don't Break On Guarded &Exceptions",
- "--at the end of debug", "debug/noerrors");
-
- // Disable the Debug menu altogether
-
- debugMenu.disable = function()
- {
- this.run.enabled =
- this.into.enabled =
- this.over.enabled =
- this.out.enabled =
- this.bptoggle.enabled =
- this.bpclearall.enabled =
- this.stop.enabled =
- this.pause.enabled =
- this.noErrors.enabled = false;
- }
-
- // Set the state of the debugging options according to the document settings
-
- debugMenu.reflectState = function()
- {
- // the current debugger may not yet have been created in the startup phase
- if (!document || !currentDebugger)
- this.disable();
- else
- {
- var running = (currentDebugger.state == Debugger.RUNNING);
- var stopped = (currentDebugger.state == Debugger.STOPPED);
- var waiting = (currentDebugger.state == Debugger.WAITING);
- switch (document.status)
- {
- case "noexec":
- // not executable
- this.disable();
- break;
- case "exec":
- // standard executable
- this.run.enabled =
- this.into.enabled =
- this.over.enabled = !running || stopped;
- this.out.enabled = stopped;
- this.bptoggle.enabled =
- this.bpclearall.enabled = true;
- this.stop.enabled = running || stopped;
- this.pause.enabled = running;
- break;
- case "dynamic":
- // dynamic script, not saveable
- this.run.enabled =
- this.into.enabled =
- this.over.enabled =
- this.out.enabled =
- this.bptoggle.enabled =
- this.bpclearall.enabled =
- this.stop.enabled = stopped;
- this.pause.enabled = false;
- break;
- }
- }
- }
-
- debugMenu.run.onSelect = function()
- {
- if (currentDebugger.state == Debugger.STOPPED)
- currentDebugger.doContinue();
- else if (document)
- currentDebugger.start (document, 1);
- }
-
- debugMenu.into.onSelect = function()
- {
- if (currentDebugger.state == Debugger.STOPPED)
- currentDebugger.execute ("StepInto");
- else if (document)
- currentDebugger.start (document, 2);
- }
-
- debugMenu.over.onSelect = function()
- {
- if (currentDebugger.state == Debugger.STOPPED)
- currentDebugger.execute ("StepOver");
- else if (document)
- currentDebugger.start (document, 2);
- }
-
- debugMenu.out.onSelect = function()
- {
- if (currentDebugger.state == Debugger.STOPPED)
- currentDebugger.execute ("StepOut");
- }
-
- debugMenu.pause.onSelect = function()
- {
- if (currentDebugger.isActive())
- {
- currentDebugger.execute ("Stop");
- debugMenu.reflectState();
- }
- }
-
- debugMenu.stop.onSelect = function()
- {
- if (currentDebugger.isActive())
- {
- currentDebugger.execute ("Halt");
- debugMenu.reflectState();
- }
- }
-
- debugMenu.bptoggle.onDisplay =
- debugMenu.bpclearall.onDisplay = function()
- {
- this.enabled = (document != null);
- }
-
- debugMenu.bptoggle.onSelect = function()
- {
- var at = document.getSelection()[0];
- document.toggleBP (document.offsetToLine (at));
- }
-
- debugMenu.bpclearall.onSelect = function()
- {
- document.clearAllBP();
- }
-
- debugMenu.noErrors.onDisplay = function()
- {
- this.checked = prefs.dontBreakOnErrors;
- }
-
- debugMenu.noErrors.onSelect = function()
- {
- prefs.dontBreakOnErrors = !prefs.dontBreakOnErrors;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // The Profile menu.
- // Profile display mode: 0 - nothing, 1 - hits, 2 - time
- // Profiling level:
- // 0 - no profiling (default)
- // 1 - function level profiling
- // 2 - function level profiling with timing information
- // 3 - line level profiling
- // 4 - line level profiling with timing information.
-
- var profileMenu = new MenuElement ("menu", "$$$/ESToolkit/Menu/Profile=&Profile",
- "after debug", "profile");
- profileMenu.off = new MenuElement ("command", "$$$/ESToolkit/Menu/Profile/Off=&Off",
- "at the end of profile", "profile/off");
- profileMenu.functions = new MenuElement ("command", "$$$/ESToolkit/Menu/Profile/Functions=&Functions",
- "at the end of profile", "profile/functions");
- profileMenu.lines = new MenuElement ("command", "$$$/ESToolkit/Menu/Profile/Lines=&Lines",
- "at the end of profile", "profile/lines");
- profileMenu.timing = new MenuElement ("command", "$$$/ESToolkit/Menu/Profile/Timing=&Add Timing Info",
- "----at the end of profile", "profile/timing");
- profileMenu.none = new MenuElement ("command", "$$$/ESToolkit/Menu/Profile/None=&No Profiler Data",
- "----at the end of profile", "profile/none");
- profileMenu.hits = new MenuElement ("command", "$$$/ESToolkit/Menu/Profile/Hits=Show &Hit Count",
- "at the end of profile", "profile/hits");
- profileMenu.time = new MenuElement ("command", "$$$/ESToolkit/Menu/Profile/Time=Show &Timing",
- "at the end of profile", "profile/time");
- profileMenu.clear = new MenuElement ("command", "$$$/ESToolkit/Menu/Profile/Clear=&Erase Profiler Data",
- "----at the end of profile", "profile/clear");
- profileMenu.save = new MenuElement ("command", "$$$/ESToolkit/Menu/Profile/SaveAs=Save Profiler Data &As...",
- "----at the end of profile", "profile/save");
-
- profileMenu.off.onDisplay = function()
- {
- this.checked = (prefs.profileLevel == 0);
- }
-
- profileMenu.off.onSelect = function()
- {
- profileMenu.setLevel (0);
- }
-
- profileMenu.functions.onDisplay = function()
- {
- this.checked = (prefs.profileLevel == 1 || prefs.profileLevel == 2);
- }
-
- profileMenu.functions.onSelect = function()
- {
- profileMenu.setLevel (prefs.profileTiming ? 2 : 1);
- documents.setProfDisplayMode (prefs.profDisplayMode);
- }
-
- profileMenu.lines.onDisplay = function()
- {
- this.checked = (prefs.profileLevel == 3 || prefs.profileLevel == 4);
- }
-
- profileMenu.lines.onSelect = function()
- {
- profileMenu.setLevel (prefs.profileTiming ? 4 : 3);
- documents.setProfDisplayMode (prefs.profDisplayMode);
- }
-
- profileMenu.timing.onDisplay = function()
- {
- this.enabled = (prefs.profileLevel != 0);
- this.checked = (prefs.profileLevel == 2 || prefs.profileLevel == 4);
- }
-
- profileMenu.timing.onSelect = function()
- {
- prefs.profileTiming = !prefs.profileTiming;
- if (prefs.profileLevel)
- {
- if (prefs.profileTiming)
- profileMenu.setLevel (prefs.profileLevel == 1 ? 2 : 4);
- else
- {
- profileMenu.setLevel (prefs.profileLevel == 2 ? 1 : 3);
- // reset display mode to Hit Count if Times was selected
- if (prefs.profDisplayMode == 2)
- {
- prefs.profDisplayMode = 1;
- documents.setProfDisplayMode (1);
- }
- }
- }
- }
-
- profileMenu.none.onDisplay = function()
- {
- this.enabled = (prefs.profileLevel != 0);
- this.checked = (prefs.profDisplayMode == 0);
- }
-
- profileMenu.none.onSelect = function()
- {
- prefs.profDisplayMode = 0;
- documents.setProfDisplayMode (0);
- }
-
- profileMenu.hits.onDisplay = function()
- {
- this.enabled = (prefs.profileLevel != 0);
- this.checked = (prefs.profDisplayMode == 1);
- }
-
- profileMenu.hits.onSelect = function()
- {
- prefs.profDisplayMode = 1;
- documents.setProfDisplayMode (1);
- }
-
- profileMenu.time.onDisplay = function()
- {
- this.enabled = prefs.profileTiming;
- this.checked = (prefs.profDisplayMode == 2);
- }
-
- profileMenu.time.onSelect = function()
- {
- prefs.profDisplayMode = 2;
- documents.setProfDisplayMode (2);
- }
-
- profileMenu.clear.enabled = true;
-
- profileMenu.clear.onSelect = function()
- {
- documents.clearProfData();
- }
-
- profileMenu.save.onDisplay = function()
- {
- this.enabled = (prefs.profileLevel > 0);
- }
-
- profileMenu.save.onSelect = function()
- {
- documents.saveProfData();
- }
-
- profileMenu.setLevel = function (level)
- {
- prefs.profileLevel = level;
- if (currentDebugger.state == Debugger.STOPPED)
- currentDebugger.profileLevel = level;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // The Window menu
-
- var windowMenu = MenuElement.find ("window");
- windowMenu.showAll = new MenuElement ("command",
- "$$$/ESToolkit/Menu/Window/ShowAll=&Show All",
- "before window/1---", "window/showAll");
-
- windowMenu.showAll.enabled = true;
-
- windowMenu.showAll.onSelect = function()
- {
- var i;
- for (i = 0; i < window.panes.length; i++)
- window.panes [i].visible = true;
- for (i = 0; i < documents.length; i++)
- documents [i].visible = true;
- }
-
-
- //////////////////////////////////////////////////////////////////////////
- // The context menu for the Variables pane
-
- var variablesContextMenu = {};
-
- variablesContextMenu.functions = new MenuElement ("command",
- "$$$/ESToolkit/Menu/Variables/Functions=Show Global &Functions",
- "----at the end of variables", "variables/functions");
- variablesContextMenu.methods = new MenuElement ("command",
- "$$$/ESToolkit/Menu/Variables/Methods=Show Object &Methods",
- "at the end of variables", "variables/methods");
- variablesContextMenu.predefined = new MenuElement ("command",
- "$$$/ESToolkit/Menu/Variables/Predefined=Show &JavaScript Language Elements",
- "at the end of variables", "variables/predefined");
-
- variablesContextMenu.functions.enabled =
- variablesContextMenu.methods.enabled =
- variablesContextMenu.predefined.enabled = true;
-
- variablesContextMenu.functions.onDisplay = function()
- {
- this.checked = prefs.showFunctions;
- }
-
- variablesContextMenu.methods.onDisplay = function()
- {
- this.checked = prefs.showMethods;
- }
-
- variablesContextMenu.predefined.onDisplay = function()
- {
- this.checked = prefs.showPredefined;
- }
-
- variablesContextMenu.functions.onSelect = function()
- {
- prefs.showFunctions = !prefs.showFunctions;
- window.variables.refresh();
- }
-
- variablesContextMenu.methods.onSelect = function()
- {
- prefs.showMethods = !prefs.showMethods;
- window.variables.refresh();
- }
-
- variablesContextMenu.predefined.onSelect = function()
- {
- prefs.showPredefined = !prefs.showPredefined;
- window.variables.refresh();
- }
-
- //////////////////////////////////////////////////////////////////////////
- // The context menu for the Editor
-
- var editContextMenu = {}
-
- editContextMenu.none = new MenuElement ("command", "$$$/ESToolkit/Menu/Profile/None=&No Profiler Data",
- "----at the end of context/document", "context/document/none");
- editContextMenu.hits = new MenuElement ("command", "$$$/ESToolkit/Menu/Profile/Hits=Show &Hit Count",
- "at the end of context/document", "context/document/hits");
- editContextMenu.time = new MenuElement ("command", "$$$/ESToolkit/Menu/Profile/Time=Show &Timing",
- "at the end of context/document", "context/document/time");
- editContextMenu.clear = new MenuElement ("command", "$$$/ESToolkit/Menu/Profile/Clear=&Erase Profiler Data",
- "at the end of context/document", "context/document/clear");
-
- //editContextMenu.check.enabled =
- editContextMenu.none.enabled =
- editContextMenu.hits.enabled =
- editContextMenu.time.enabled =
- editContextMenu.clear.enabled = true;
-
- editContextMenu.none.onDisplay = function()
- {
- this.checked = (document.profileDisplayMode == 0);
- }
-
- editContextMenu.none.onSelect = function()
- {
- document.profileDisplayMode = 0;
- }
-
- editContextMenu.hits.onDisplay = function()
- {
- this.checked = (document.profileDisplayMode == 1);
- }
-
- editContextMenu.hits.onSelect = function()
- {
- document.profileDisplayMode = 1;
- }
-
- editContextMenu.time.onDisplay = function()
- {
- this.enabled = prefs.profileTiming;
- this.checked = (document.profileDisplayMode == 2);
- }
-
- editContextMenu.time.onSelect = function()
- {
- document.profileDisplayMode = 2;
- }
-
- editContextMenu.clear.enabled = true;
-
- editContextMenu.clear.onSelect = function()
- {
- document.clearProfData();
- }
-
- /////////////////////////////////////////////////////////
- // The Editor Line Numbers contextual menu
-
- var editLineContextMenu = MenuElement.find ("context/doclines");
- editLineContextMenu.bptoggle = new MenuElement ("command",
- "$$$/ESToolkit/Menu/Debug/ToggleBP=To&ggle Breakpoint",
- "---at the end of context/doclines", "context/doclines/bptoggle");
- editLineContextMenu.bpedit = new MenuElement ("command",
- "$$$/ESToolkit/Menu/Debug/EditBP=&Edit Breakpoint...",
- "at the end of context/doclines", "context/doclines/bpedit");
- editLineContextMenu.bpclearall = new MenuElement ("command",
- "$$$/ESToolkit/Menu/Debug/ClearAllBP=&Clear All Breakpoints",
- "---at the end of context/doclines", "context/doclines/bpclearall");
- editLineContextMenu.nextStatement= new MenuElement ("command", "$$$/ESToolkit/Menu/Debug/NextStatement=Show Next Statement",
- "---at the end of context/doclines", "context/doclines/nextStatement");
- editLineContextMenu.stopHere = new MenuElement ("command",
- "$$$/ESToolkit/Menu/Debug/RunToThisLine=Run To This &Line",
- "at the end of context/doclines", "context/doclines/stophere");
-
- editLineContextMenu.stopHere.onDisplay = function()
- {
- this.enabled = debugMenu.run.enabled;
- }
-
- editLineContextMenu.nextStatement.onDisplay = function()
- {
- this.enabled = currentDebugger.state == Debugger.STOPPED;
- }
-
- editLineContextMenu.bpedit.onDisplay =
- editLineContextMenu.bptoggle.onDisplay =
- editLineContextMenu.bpclearall.onDisplay = function()
- {
- this.enabled = (document != null);
- }
-
- editLineContextMenu.nextStatement.onSelect = function()
- {
- currentDebugger.showNextStatement();
- }
-
- editLineContextMenu.stopHere.onSelect = function()
- {
- var line = document.rightClickLine;
- document.tempBP = line;
- debugMenu.run.onSelect();
- }
-
- editLineContextMenu.bpedit.onSelect = function()
- {
- var line = document.rightClickLine;
- if (!document.isBP (line))
- document.toggleBP (line);
- window.breakpoints.editBP (line);
- }
-
- editLineContextMenu.bptoggle.onSelect = function()
- {
- document.toggleBP (document.rightClickLine);
- }
-
- editLineContextMenu.bpclearall.onSelect = function()
- {
- document.clearAllBP();
- }
-
- /////////////////////////////////////////////////////////
-
- // Additions to the Scripts context menu
-
- var scriptsContextMenu = MenuElement.find ("context/scripts");
- scriptsContextMenu.refresh = new MenuElement("command", "$$$/ESToolkit/ContextMenu/Scripts/Refresh=&Refresh",
- "----at the end of context/scripts", "context/scripts/refresh");
-
- scriptsContextMenu.refresh.enabled = true;
-
- scriptsContextMenu.refresh.onSelect = function()
- {
- window.scripts.getScripts();
- }
-
-